package com.okami.designpatterns.single;

/**
 * @description: 静态内部类实现
 * @author: TanJingyu
 * @create: 2020-12-15 11:32
 **/
class SingtonStaticInnerClass {
    private static SingtonStaticInnerClass instance;

    public static SingtonStaticInnerClass getInstance() {
        if (instance == null) {
            instance = GetInstance.instance;
        }
        return instance;
    }

    // SingtonStaticInnerClass加载，虽然static, GetInstance并不会加载
    private static class GetInstance {
        private static SingtonStaticInnerClass instance = new SingtonStaticInnerClass();
    }
}
